Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: get zig build test working #18207

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

test: get zig build test working #18207

wants to merge 25 commits into from

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Mar 15, 2025

What does this PR do?

Lets us write and run unit tests directly in Zig.

Running Zig unit tests in CI is blocked by ziglang/zig#23281. We can un-comment relevant code once this is fixed.

Workflow

I'll finish writing this up later, but some initial points are below.
Tl;Dr: bun build:test

Test binaries can be made for any kind of build. They are called <bun>-test and live next to their corresponding bun bin. For example, debug tests compile to build/debug/bun-debug-test.

Test binaries re-use most cmake/zig build steps from normal bun binaries, so building one after a normal bun build is pretty fast.

How did you verify your code works?

I tested that my tests run tests.

@robobun
Copy link

robobun commented Mar 15, 2025

Updated 6:07 PM PT - Mar 25th, 2025

@DonIsaac, your commit 685c89f has 1 failures in Build #13942:


🧪   try this PR locally:

bunx bun-pr 18207

@DonIsaac DonIsaac requested a review from 190n March 20, 2025 23:04
Copy link
Collaborator

@190n 190n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly nits, and I think this should be reviewed by someone else more familiar with the build system and CI than me

const obj = Build.LazyPath{ .generated = .{
.file = bin.generated.file,
.up = 1,
.sub_path = "bun-test.o",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you file an issue with Zig asking for a better way to do this and link it here as a TODO?

@DonIsaac
Copy link
Contributor Author

DonIsaac commented Mar 24, 2025

Tests in other files cannot be universially included via refAllDecls(bun) right now due to this crash. We can work around this using _ = @import("path/to/file.zig");

@DonIsaac DonIsaac marked this pull request as ready for review March 26, 2025 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants